package com.javase.SY04;

public class MyRectangle {

    int xUp,yUp,xDown, yDown;

    public MyRectangle(int xUp, int yUp, int xDown, int yDown) {
        this.xUp = xUp;
        this.yUp = yUp;
        this.xDown = xDown;
        this.yDown = yDown;
    }

    //计算矩形宽度
    public int getW(){
        int width=xDown-xUp;
        return Math.abs(width);
    }
    //计算矩形高度
    public int getH(){
        int height=yUp-yDown;
        return Math.abs(height);
    }
    //计算矩形面积
    public int area(){
        int width = Math.abs(xDown - xUp);
        int height = Math.abs(yUp - yDown);
        int area = width * height;
        return area;
    }
}
